<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
 '
 ' Copyright 2007 Liu, Xiaokang <4341322@gmail.com>
 ' Blog <http://www.ioio.name/>
 ' 
 ' This file is part of JOS(Judge Online System).
 ' You can see this project at <http://code.google.com/p/judgeonline/>
 ' 
 ' JOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
 ' published by the Free Software Foundation; either revision 3 of the License, or (at your option) any later revision.
 ' 
 ' JOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 ' 
 ' You should have received a copy of the GNU General Public License along with JOS. if not, see
 ' <http://www.gnu.org/licenses/>.
 '
%>
<%Option Explicit%>
<%
	Dim PageTitle
  PageTitle="Print Your Code"
%>
<!--#include file="Contest_Header.asp"-->
<script src="Styles/show_ln.js" language="javascript" type="text/javascript"></script>
<%
Dim Submitname
Submitname=Request.form("Submit")
If Submitname="Submit" Then
Dim Uid
Uid = Session("Uid")
Cid = Trim(Request.Form("ContestId"))

If  Cid<>"" and Uid<>"0" Then
	    Dim Sc,Pr,Stime,Etime
		conn.Open connstr		
		Set Pr = Server.CreateObject("ADODB.Recordset")
		Pr.Open "Select StartTime,EndTime  From [Contests] Where Cid="+Trim(Request.form("ContestId")),conn,1,3
		If  Pr.eof Or Pr.Bof Then
		Response.Write("No that Contest "+Cid)
		Else
		Stime=Pr("StartTime")
		Etime=Pr("EndTime")
		Pr.Close
		Set Pr=Nothing

		Set Sc = Server.CreateObject("ADODB.Recordset")
		Sc.Open "Select TOP 1 * from [Contest_Print] ",conn,1,3 
		Sc.AddNew
		Sc("Uid")=Uid
		Sc("Cid")=Cid
		Sc("Contents")=Trim(Request.form("TextBody"))
		Sc.Update	
		Sc.Close
		Set Sc=Nothing				
		Response.Write("Your request has been received , please wait patiently !")
		End If
End If
Else
%><div id="Main" style="min-height:400px;background-color:#FFF;">
  <div class="SubmitForm" id="SubmitForm">
  <%If Not Isempty(Request.QueryString("Cid")) Then%>
  Print Your Code
    <form name="form1" method="post" action="Contest_Print.asp?Cid=<%=Cid%>">
	<table border="0" cellpadding="0" cellspacing="0" style="width:600px;">
          <tr>
		    <td>Current Team:
			<%If IsLogin Then 
			Response.Write(Request.Cookies(CookiesName)("Username"))
			Else
			Response.Redirect("Login.asp")
			Response.End
            End if%></td>			
		  </tr>
		  <tr style="display:none;">
		    <td>ContestID:<input name="ContestId" type="text" value="<%=CInt(Request.QueryString("Cid"))%>">  
            <input name="Uid" type="text" value="<%=CInt(Request.Cookies(CookiesName)("Uid"))%>">
			</td>			
		  </tr>
		  <tr>
            <td>
			Content:<br>
              <textarea id='Text_ln' name='content' rows='20' cols='4' style='overflow:hidden;border-right:0px;text-align:right' readonly></textarea>
			  <textarea name="TextBody" cols="60" rows="20" wrap="VIRTUAL" id="TextBody" onkeydown='editTab()' onchange='show_ln()' onscroll='show_ln()' style='overflow:auto;padding-left:5px;border-left:0px'></textarea>
			  <script> for(var i=1; i<=20; i++) document.getElementById('Text_ln').value += i + '\n';</script>
            </td>       
          </tr>
		  <tr>
            <td><div class="Submit_box" id="Submit_box">
			<input type="submit" name="Submit" value="Submit" class="Submit_Submit"></div>
            </td>       
          </tr>
		  <!--<tr>
            <td><div class="Submit_box" id="Submit_box">
              <input type="submit" name="Submit2" value="Reset" onClick="TextBody.value='';" class="Submit_Submit"></div>
            </td>       
          </tr>-->
        </table>
    </form>
    <%End If%>
  </div>
</div>
 <%End If%>
<!--#include file="Footer.asp"-->
